import 'package:fate_blind_box/theme/theme_color.dart';
import 'package:fate_blind_box/utils/default/common_config.dart';
import 'package:fate_blind_box/utils/map/screen_utils.dart';
import 'package:fate_blind_box/utils/page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher_string.dart';


class DownloadAppUiNew extends StatefulWidget {
  const DownloadAppUiNew({Key? key}) : super(key: key);

  @override
  State<DownloadAppUiNew> createState() => _DownloadAppUIState();
}

class _DownloadAppUIState extends State<DownloadAppUiNew> {
  @override
  Widget build(BuildContext context) {
    final _size = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: Colors.white,
      body: SingleChildScrollView(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(
              color: Colors.white,
              height: ScreenUtils().statusBarHeight + 20,
            ),
            Image.asset(
              "images/ic_download_web.png",
              width: _size.width,
              height: _size.width * 375 / 382,
              fit: BoxFit.fill,
            ),
            const SizedBox(
              height: 36,
            ),
            Column(
              children: [
                getCornerBtn('安卓下载',callAction: () async{
                  String str =
                      'http://6ftb7.fir.run/downpage/d4bf51363a8044a2';
                  await launchUrlString(str);
                }),
               const SizedBox(height: 20,),
                getCornerBtn('苹果下载',callAction: () async{
                  String str = CommonConfig.appStoreUrl;
                  await launchUrlString(str);
                }),
                const SizedBox(height: 20,),
                GestureDetector(
                  onTap: (){
                    Navigate.toMain();
                  },
                  child:   Column(
                    children: [
                      Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          Text('进入主页',style: TextStyle(fontSize:14,color: ThemeColor.appColor),),
                          Icon(Icons.arrow_forward_ios_rounded,color: ThemeColor.appColor,size: 14,),
                        ],
                      ),
                      Container(
                        height: 1,
                        width: 72,
                        color: ThemeColor.appColor,
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }

  Widget getCornerBtn(String name,{Function?callAction}) {
    return GestureDetector(
      onTap: (){
        if(callAction!=null){
          callAction();
        }
      },
      child: Container(
        height: 45,
        decoration: BoxDecoration(
            color: ThemeColor.appColor,
            borderRadius: BorderRadius.circular(23)),
        alignment: Alignment.center,
        margin: EdgeInsets.symmetric(horizontal: 78),
        child: Text(
          name,
          style: TextStyle(color: Colors.white),
        ),
      ),
    );
  }
}
